package com.ruoyi.ihome.service.impl;

import java.util.List;

import com.ruoyi.common.core.redis.RedisCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ihome.mapper.IhCheckMapper;
import com.ruoyi.ihome.domain.IhCheck;
import com.ruoyi.ihome.service.IIhCheckService;

/**
 * 房间入住期限Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-08-15
 */
@Service
public class IhCheckServiceImpl implements IIhCheckService 
{
    @Autowired
    private IhCheckMapper ihCheckMapper;

    @Autowired
    private RedisCache redisCache;

    /**
     * 查询房间入住期限
     * 
     * @param id 房间入住期限主键
     * @return 房间入住期限
     */
    @Override
    public IhCheck selectIhCheckById(Long id)
    {
        return ihCheckMapper.selectIhCheckById(id);
    }

    /**
     * 查询房间入住期限列表
     * 
     * @param ihCheck 房间入住期限
     * @return 房间入住期限
     */
    @Override
    public List<IhCheck> selectIhCheckList(IhCheck ihCheck)
    {
        // 涉及分页查数据库
        if (ihCheck != null)
            return ihCheckMapper.selectIhCheckList(ihCheck);
        // 查询全部查缓存
        List<IhCheck> list = (List<IhCheck>) redisCache.getCacheObject("selectIhCheckList");
        if (list == null){
            list = ihCheckMapper.selectIhCheckList(ihCheck);
            redisCache.setCacheObject("selectIhCheckList",list);
        }
        return list;
    }

    /**
     * 新增房间入住期限
     * 
     * @param ihCheck 房间入住期限
     * @return 结果
     */
    @Override
    public int insertIhCheck(IhCheck ihCheck)
    {
        return ihCheckMapper.insertIhCheck(ihCheck);
    }

    /**
     * 修改房间入住期限
     * 
     * @param ihCheck 房间入住期限
     * @return 结果
     */
    @Override
    public int updateIhCheck(IhCheck ihCheck)
    {
        return ihCheckMapper.updateIhCheck(ihCheck);
    }

    /**
     * 批量删除房间入住期限
     * 
     * @param ids 需要删除的房间入住期限主键
     * @return 结果
     */
    @Override
    public int deleteIhCheckByIds(Long[] ids)
    {
        return ihCheckMapper.deleteIhCheckByIds(ids);
    }

    /**
     * 删除房间入住期限信息
     * 
     * @param id 房间入住期限主键
     * @return 结果
     */
    @Override
    public int deleteIhCheckById(Long id)
    {
        return ihCheckMapper.deleteIhCheckById(id);
    }
}
